package com.guobox.movies.view.activity;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import com.guobox.movies.APP;
import com.guobox.movies.R;
import com.guobox.movies.constant.Constant;
import com.guobox.movies.entity.BgColors;
import com.guobox.movies.view.mview.BgView;


public class TMovieReviewActivity extends Activity {

    BgView bgView ;
    TextView movieAbstract;
    BgColors bgColors;
    String text = "", director = "", writer = "", actor = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tmovie_abstract);

        initData();
        initView();
    }
    void initData(){
        if (getIntent().getAction() == null) {
            return;
        }
        if (getIntent().getAction().equals(Constant.REVIEW)) {
            text = getIntent().getStringExtra(Constant.REVIEW);
        } else if (getIntent().getAction().equals(Constant.ACTORS)) {
            director = replaceNull(getIntent().getStringExtra(Constant.DIRECTOR));
            writer = replaceNull(getIntent().getStringExtra(Constant.WRITER));
            actor = replaceNull(getIntent().getStringExtra(Constant.ACTOR));
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("导演: ");
            stringBuilder.append(director.replaceAll("/", " / "));
            stringBuilder.append("\n");
            stringBuilder.append("编剧: ");
            stringBuilder.append(writer.replaceAll("/", " / "));
            stringBuilder.append("\n");
            stringBuilder.append("演员: ");
            stringBuilder.append(actor.replaceAll("/", " / "));
            text = stringBuilder.toString();
        }
        bgColors = (BgColors) getIntent().getSerializableExtra(Constant.COLORS);
    }
    private void initView(){
        bgView = (BgView) findViewById(R.id.bg_movie_abstract);
        bgView.setColos(bgColors);
        movieAbstract = (TextView) findViewById(R.id.tv_movie_abstract);
        movieAbstract.setTextColor(bgColors.getMainTextColor());
        movieAbstract.setText(text);
        movieAbstract.setTypeface(APP.getTypeface());
    }

    private String replaceNull(String s) {
        if (TextUtils.isEmpty(s)) {
            return "-";
        }else
            return s;
    }
}
